package com.qf.android.huihui.presenter;

import com.qf.android.huihui.bean.SearchBean;
import com.qf.android.huihui.model.SearchModel;
import com.qf.android.huihui.model.impl.ISearch;
import com.qf.android.huihui.presenter.impl.BasePresenter;
import com.qf.android.huihui.view.activity.impl.ISearchView;

import rx.Observable;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by lx on 2017/1/12.
 */

public class SearchPresenter implements BasePresenter {
    private ISearch model;
    private ISearchView view;

    public SearchPresenter(ISearchView view) {
        this.view = view;
        model=new SearchModel();
    }

    @Override
    public void getData() {
        final Observable<SearchBean> beans =model.loadInfo();
        beans.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<SearchBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(SearchBean bean) {
                        view.setDate(bean);
                    }
                });
    }

    @Override
    public void getData(Object page, Object type, boolean isUpfresh, boolean isDownfresh, Object adapter, Object recyclerview) {

    }
}
